<?php
require $_SERVER['DOCUMENT_ROOT'].'/../_core/common.php';

$db = new DB('news');

$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
$k = isset($_POST['k']) ? intval($_POST['k']) : 0;

if($id<=0||$k<=0){
	exit;
}

$category_sql = 'select id,child_id,orders,top_id,title from categories where parent_id='.$id.' and is_del=1 order by orders desc';
$category_rs = $db->query($category_sql)->getAll();
$string = '';
foreach($category_rs as $category_rss){
	$string .= '
		<tr height="25">
			<td width="86" class="text_align_center" id="category_'.$category_rss['id'].'">';
	if(!empty($category_rss['child_id'])){
		$string .= '<a href="javascript:;" onclick="get_category(1,'.$category_rss['id'].','.($k+1).')">[+]</a>';
	}else{
		$string .= '&nbsp;';
	}
	$string .= '
			</td>
			<td width="50" class="td_text_center">'.$category_rss['id'].'</td>
			<td width="150" class="td_text_center">'.$category_rss['orders'].'</td>
			<td style="padding-left:'.(10+$k*30).'px;width:'.(800-$k*30).'px;" class="column_title">└ '.$category_rss['title'].'</td>
			<td width="150" class="td_text_center">
				<a href="/admin/news/category/category_add.php?parent_id='.$category_rss['id'].'&top_id=0">新增</a>
				<a href="/admin/news/category/category_edit.php?id='.$category_rss['id'].'">编辑</a>
				<a href="javascript:del_category('.$category_rss['id'].');" onclick="return confirm(\'确定删除《'.$category_rss['title'].'》栏目吗？\')">删除</a>
			</td>
		</tr>';
	if(!empty($category_rss['child_id'])){
		$string .= '<tr id ="category_toggle_'.$category_rss['id'].'" style="display:none;" ><td colspan="5"><table class="secondCategory category_'.$category_rss['id'].'" width="100%"></table></td></tr>';
	}
}

echo $string;